<?php

function showImages($id) {
	$sql = 'SELECT *
		FROM upload
		WHERE objectid='.$id;

	$result = mysql_query($sql);
	$ret = "";
	while ($row = mysql_fetch_array($result))
		$ret .= ("<a href='page/img.php?id=".$row["uploadid"]."' target='blank'><img width='250' src='page/img.php?id=".$row["uploadid"]."'></a> ");
	return $ret;
}

if ($id == "") {
	$sql = 'SELECT *
		FROM objects
		WHERE 1'.
		($paytype == '' ? '' : " AND paytype = '$paytype'").
		($type == '' ? '' : " AND type = '$type'");

	$result = mysql_query($sql);

	echo ('<table align="center">');
	while ($row = mysql_fetch_array($result))
		echo ("
			<tr>
				<td><a href=?page=show&id=".$row["id"]."&paytype=$paytype&type=$type>".$row["title"]."</td>
			</tr>");
	echo ("</table>");
} else {
	$sql = "SELECT *
		FROM objects
		WHERE id = '$id'";

	$result = mysql_query($sql);

	$row = mysql_fetch_array($result);

	echo ("
	<table>
		<tr>
			<td valign='top' width='250'>".preg_replace('/\n/', '<br>', $row["title"])."</td>
			<td valign='top'>".preg_replace('/\n/', '<br>', $row["text"])."</td>
		</tr>
		<tr>
			<td colspan='2'>&nbsp;</td>
		</tr>
		<tr>
			<td colspan='2'>".showImages($id)."</td>
		</tr>
	</table>");
}